package cn.luckywh.dao;

import cn.luckywh.pojo.User;
import com.sun.xml.internal.bind.v2.model.core.ID;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author w.
 * @date 2020/11/25 17:36
 */
public interface UserMapper {

    @Select("select * from user")
    List<User> getUsers();

    //方法存在多个参数，每个参数前面必须加上@Param注解
    @Select("select * from user where id = #{id}")
    User getUserById(@Param("id") int id);

    @Insert("insert into user (id,username,birthday,sex,address) value (#{id},#{username},#{birthday},#{sex},#{address})")
    int addUser(User user);


    @Update("update user set username=#{username},birthday=#{birthday},sex=#{sex},address=#{address}  where id = #{id}")
    int updateUser(User user);

    @Delete(" delete from user where id = #{id}")
    int deleteUser(@Param("id") int id);
}
